package com.ccit.order.controller;

import com.ccit.common.result.Result;
import com.ccit.model.Reservation;
import com.ccit.model.vo.Reservation.ReservationVo;
import com.ccit.order.service.ReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;

@RestController
@RequestMapping("/reservation")
public class ReservationController {
    @Autowired
    private ReservationService reservationService;

    //    查询所有预约信息
    @GetMapping("/findAllReservation")
    public Result<List<Reservation>> findAllReservation() {
        List<Reservation> list = reservationService.findAllReservation();
        return Result.ok(list);
    }

    //    添加预约信息
    @PostMapping("/addReservation")
    public Result<Object> addReservation(@RequestBody ReservationVo reservation) {
        reservationService.addReservation(reservation);
        return Result.ok("新增成功");
    }

    //    删除预约信息
    @GetMapping("/deleteReservation")
    public Result<Object> deleteReservation(@RequestParam String uuid) {
        reservationService.deleteReservation(uuid);
        return Result.ok("删除成功");
    }

    //    修改预约信息
    @PostMapping("/updateReservation")
    public Result<Object> updateReservation(@RequestBody ReservationVo reservation) {
        reservationService.updateReservation(reservation);
        return Result.ok("修改成功");
    }


}
